package pkg.hicph.org;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;


public class ChooseMoneyScreen extends Activity implements OnClickListener  {
    
    public TextView chooseMoneyInfo, chooseMoneyTitle;
    public Button recycleButton, beggingButton, husForbiButton;


	@Override
	public void onCreate(Bundle savedInstanceState) {
	  super.onCreate(savedInstanceState);
	  
	  requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(
      WindowManager.LayoutParams.FLAG_FULLSCREEN,
      WindowManager.LayoutParams.FLAG_FULLSCREEN);
	  
	  setContentView(R.layout.choosemoneyscreen);
	  
	  registerViews();
	  setupOnClickListeners();
	  
	  chooseMoneyTitle.setText("You decided to go and get some money.");
	  chooseMoneyInfo.setText("Looking around, you notice that there are only 3 ways of getting money around here: recycling bottles and cans, begging for money, and selling the Hus Forbi newspapers you have with you.\n\n What are you going to do?");
	  
	}
	
	
//	private void loadPrefs() {
//		
//		String actionName;
//		
//    	preferences  = getSharedPreferences(PREF_FILE, MODE_PRIVATE);
//    	
//    	actionName = preferences.getString("nextActionName", "");
//    	
//    	Log.d("DIALOG","loaded: " + actionName);
//    	
//    	actionToPerform = Utils.nextAction;
//    	
//    	actionToPerform = Utils.getActionByName(actionName);
//    	Log.d("DIALOG","action: " + actionToPerform.name);
//        
//	}
	
	
	private void registerViews() {
			
		 recycleButton = (Button) this.findViewById(R.id.choose_recycle_button);
		 beggingButton = (Button) this.findViewById(R.id.choose_begging_button);
		 husForbiButton = (Button) this.findViewById(R.id.choose_husforbi_button);
		 chooseMoneyInfo = (TextView) this.findViewById(R.id.choose_money_info);
		 chooseMoneyTitle = (TextView) this.findViewById(R.id.choose_money_title);
	}

	
	public void setupOnClickListeners() {
        
		recycleButton.setOnClickListener(this);
		beggingButton.setOnClickListener(this);
		husForbiButton.setOnClickListener(this);

    }
    
	
    public void onClick(View V) {
    	
    	switch(V.getId()) {
    	
    	case R.id.choose_recycle_button:

    		Utils.gamePhase = Utils.START_RECYCLE_MODE;
    		
    		Utils.player.dayStory += "\n\nYou went looking at trash bins for bottles and cans to recycle.";
    		
    		// CLOSES THE DIALOG
    		this.finish();
    		
    		break;
    		
    	case R.id.choose_begging_button:

    		Utils.gamePhase = Utils.START_BEG_MODE;
    		
    		Utils.player.dayStory += "\n\nEven though you felt bad for it, you decided to walk around begging.";
    		
    		// CLOSES THE DIALOG
    		this.finish();
    		
    		break;
    		
    	case R.id.choose_husforbi_button:
    		
    		Utils.gamePhase = Utils.START_HF_MODE;
    		
    		Utils.player.dayStory += "\n\nYou had some Hus Forbi newspapers with you, so you chose to go around selling them.";
    		
    		// CLOSES THE DIALOG
    		this.finish();
    		
    		break;
    		
    	}

    }


}



